import uuid from 'uuid'

let CodeMap = {
  1006: '文件尺寸过大',
  10104: '用户名或密码错误',
  1104: '数据不存在',
  1111: '您没有登录或登录已失效，请重新登录',
  30001: '用户不存在'
}

let TipUtil = {
  success (content = '操作成功', duration = 3) {
    let id = uuid()
    iView.Message.success({
      render (h) {
        return h('div', {
          domProps: {
            id
          }
        }, content)
      },
      duration
    })

    // addClass(id, 'success')
  },
  warning (desc = '', duration = 3) {
    iView.Notice.warning({
      title: '系统提示',
      desc,
      duration
    })
  },
  ossError (duration = 5) {
    iView.Notice.error({
      title: 'OSS Error',
      desc: '',
      duration
    })
  },
  networkError (duration = 5) {
    iView.Notice.error({
      title: 'Network Error',
      desc: '',
      duration
    })
  },
  error (msg = '', title = '系统提示', duration = 5) {
    iView.Notice.error({
      title: title,
      desc: msg,
      duration
    })
  },
  errorCode (code, duration = 5) {
    let desc = CodeMap[code] || `ErrorCode：${code}`
    iView.Notice.error({
      title: 'Error',
      desc,
      duration
    })
  }

  // success(msg = 'Operation Success', duration = 3) {
  //   iView.Message.success({
  //     content: msg,
  //     duration
  //   })
  // },
  // warning(desc = '', duration = 3) {
  //   iView.Notice.warning({
  //     title: '系统提示',
  //     desc,
  //     duration
  //   })
  // },
  // ossError(duration = 5) {
  //   iView.Notice.error({
  //     title: 'OSS Error',
  //     desc: '',
  //     duration
  //   })
  // },
  // networkError(duration = 5) {
  //   iView.Notice.error({
  //     title: 'Network Error',
  //     desc: '',
  //     duration
  //   })
  // },
  // error(msg = '', title = '系统提示', duration = 5) {
  //   iView.Notice.error({
  //     title: title,
  //     desc: msg,
  //     duration
  //   })
  // },
  // errorCode(code, duration = 5) {
  //   let desc = CodeMap[code] || `ErrorCode：${code}`
  //   iView.Notice.error({
  //     title: 'Error',
  //     desc,
  //     duration
  //   })
  // }
}

export default TipUtil
